<template>
  <div class="game-record-card">
    <Button type="primary" class="back-button" @click="$router.history.go(-1)" icon="md-arrow-back">返回上一页</Button>
    <div v-if="!loading&&unreviewed.eventsId!=null">
      <Row>
        <h3 class="title">未审核版本：</h3>
      </Row>
      <Row :gutter='32'>
        <Col span="8">
        <Card>
          <Row>
            赛事名称：<span v-text='unreviewed.eventsName'></span>
            <dict-span code="ZGX_SSSHZT" :class="'verify-status verify-status-'+unreviewed.verifyStatus" :value="unreviewed.verifyStatus"></dict-span>
          </Row>
          <Row>
            申请类型：<dict-span code='ZGX_SSCZLX' :value='unreviewed.operationType'></dict-span>
          </Row>
          <Row>
            提交人：<span v-text="unreviewed.submissionBy"></span>
          </Row>
          <Row>
            提交时间：<span v-text="$config.getTime(unreviewed.submissionTime)"></span>
          </Row>
        </Card>
        </Col>
      </Row>

    </div>
    <div v-if="!loading&&tableData.length>0">
      <Row>
        <h3 class="title">已审核版本：</h3>
      </Row>
      <Row :gutter='32'>
        <Col span="8" v-for="item in tableData">
        <Card class="verify-card">
          <Row>
            赛事名称：<span v-text='item.eventsName'></span>
            <dict-span code="ZGX_SSSHZT" :class="'verify-status verify-status-'+item.verifyStatus" :value="item.verifyStatus"></dict-span>
          </Row>
          <Row>
            申请类型：<dict-span code='ZGX_SSCZLX' :value='item.operationType'></dict-span>
          </Row>
          <Row>
            审核人：<span v-text='item.auditorBy'></span>
          </Row>
          <Row>
            审核意见：<dict-span class="m-r-sm" v-if="item.verifyReason!=null" code="ZGX_BHYY" :value="item.verifyReason"></dict-span> <span class="span-explain" v-if="item.verifyStatus!='3'" v-text='item.verifyExplain'></span>
          </Row>
          <Row>
            审核时间：<span v-text="$config.getTime(item.verifyTime)"></span>
          </Row>
        </Card>
        </Col>
      </Row>
      <page-temp :total="total" :current="page.pageNo" :size="page.pageSize" @changePage='changePage'></page-temp>
    </div>
    <spin-temp v-if="loading"></spin-temp>
  </div>
</template>

<script>
import dictSpan from "_c/dict/dict-span.vue";
import Api from "@/api/game-verify";
import ApiApply from "@/api/game-apply";
import _ from "lodash";
const api = new Api();
const apiApply = new ApiApply();
// 赛事管理
export default {
  components: {
    dictSpan
  },
  data() {
    return {
      loading: true,
      total: 0,
      pageModel: {},
      eventsId: this.$route.params.id,
      page: {
        pageSize: 6,
        pageNo: 1,
        eventsId: this.$route.params.id
      },
      units: [],
      unreviewed: {},
      tableData: []
    };
  },
  mounted() {
    let self = this;
    api.historyListPage({ ...self.page, verifyTag: 0 }).then(data => {
      if (data && data.list.length > 0) {
        self.unreviewed = data.list[0];
      }
    });
    self.fetchListStart();
  },
  methods: {
    // 获取数据
    fetchListStart() {
      let self = this;
      self.page = { ...self.page, ...self.pageModel, pageNo: 1 };
      self.fetchList();
    },
    fetchList() {
      this.loading = true;
      api
        .historyListPage(this.page)
        .then(data => {
          this.loading = false;
          this.tableData = data.list || [];
          this.total = data.count || 0;
        })
        .catch(error => {
          this.loading = false;
        });
    },
    // 分页
    changePage(pageNum) {
      this.page.pageNo = pageNum;
      this.fetchList();
    },
    reset() {
      let self = this;
      Object.keys(self.pageModel).forEach(x => {
        self.pageModel[x] = null;
      });
      this.fetchListStart();
    }
  }
};
</script>

<style lang="less" scoped>
.game-record-card {
  .title {
    margin: 5px 0px;
    font-weight: bold;
  }
  .ivu-card {
    .ivu-row {
      line-height: 32px;
    }

    margin-bottom: 32px;
  }
  .verify-card {
    height: 224px;
  }
}
</style>
